﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
namespace StoreWeb.system.lowDealers
{
    public partial class list : System.Web.UI.Page
    {
        BLL.DealersManage userdealers = new BLL.DealersManage();
        //BLL.Role role = new BLL.Role();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int totalOrders = userdealers.GetRecordCount("");
                AspNetPager1.RecordCount = totalOrders;
            }
        }
        void bindData()
        {


            if (new Maticsoft.BLL.UserAdmin().GetModel(Convert.ToInt32(Request.Cookies["UserLogin"].Values[0])).loginname == "admin")
            {//管理员可以查看所有
                Repeater1.DataSource = userdealers.GetListByPage("", " ", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
            }
            else
            {
                Repeater1.DataSource = userdealers.GetListByPage("  dealersid='" + new Maticsoft.BLL.UserAdmin().GetModel(Convert.ToInt32(Request.Cookies["UserLogin"].Values[0])).dealersid.ToString() + "' ", "", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
            }

           // Repeater1.DataSource = userdealers.GetListByPage("", " dealersid ", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex);
            Repeater1.DataBind();
        }

        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            bindData();
        }

        /// <summary>
        /// 获得用户名
        /// </summary>
        /// <param name="parentid"></param>
        /// <returns></returns>
        protected string GetUserName(String userid)
        {
            if (userid == "" || userid == "0")
            {
                return "";
            }
            else
            {
                return new BLL.DealersManage().GetModel(Convert.ToInt32(userid)).username + "【" + new BLL.DealersManage().GetModel(Convert.ToInt32(userid)).dealersgrade + "级】";
                //return "";
            }
        }
    }
}